<template>
  <!-- 下单弹出层 -->
  <view>
    <u-popup :show="showFlag" @close="close" @open="open" round="20" :safeAreaInsetBottom="false">
      <view class="popup">
        <image style="width: 40rpx; height: 40rpx; float: right" src="http://qiniu.suboshimuying.cn/static/search/ic-clear-true@2x.png" mode="" @click="close"></image>
        <view class="popup-good">
          <image :src="details.thum_image" mode=""></image>
          <view class="goodRight">
            <view>
              <text>¥</text>
              <text style="font-size: 36rpx">{{ details.price }}</text>
            </view>
            <view class="u-line-2" style="color: #323233; margin-top: 25rpx">
              {{ details.name }}
            </view>
          </view>
        </view>
        <template v-if="type === 1 || type === 3 || type === 4">
          <view class="popup-number">
            <text>数量</text>
            <view class="numberRight">
              <text @click="number > 1 ? number-- : ''">-</text>
              <text>{{ number }}</text>
              <text @click="number++">+</text>
            </view>
          </view>
        </template>

        <!-- <template v-if="type===2">
					<view class="popup-row">
						<text>服务时间</text>
						<view class="rowRight">
							<text>请选择服务时间</text>
							<image src="http://qiniu.suboshimuying.cn/static/order/ic-arrow-more@2x.png" mode=""></image>
						</view>
					</view>
				</template> -->
        <template v-if="btnType & (type !== 3) & (type !== 2)">
          <view class="popup-number">
            <text></text>
            <view class="allPrice">
              <text style="color: #000">共计:</text>
              <text>¥{{ number * Number(details.price) }}</text>
            </view>
          </view>
        </template>
        <view class="popup-btn" @click="btnClick">
          {{ btnType ? '立即购买' : '加入购物车' }}
        </view>
      </view>
    </u-popup>
    <MessageBox :showFlag="popupShow" title="该商品为特定人员专享噢" text="请注意核查是否满足条件不符合条件不退款" btnText="确认购买" @popupClose="popupShow = false" @MesBoxCallback="callback" />
  </view>
</template>

<script>
import MessageBox from '@/components/MessageBox/MessageBox.vue'
export default {
  name: 'PlacePopup',
  props: {
    // 显示弹出层
    showFlag: {
      default: false,
      type: Boolean
    },
    // 专区类型
    type: {
      type: Number,
      require: true
    },
    // 按钮类型
    btnType: {
      type: Boolean,
      default: true
    },
    // 商品信息
    details: {
      type: Object,
      require: true
    }
  },
  data() {
    return {
      number: 1,
      popupShow: false //特定人员弹出层
    }
  },
  components: {
    MessageBox
  },
  methods: {
    // 弹出层打开
    open() {
      this.number = 1
      // console.log('open');
    },
    // 弹出层关闭
    close() {
      this.$emit('popupClose')
    },
    // 按钮点击
    btnClick() {
      if (this.type === 3) {
        console.log('123')
        this.$emit('popupClose')
        this.popupShow = true
      } else {
        console.log('456')
        this.$emit('popupBtnCallback', this.number)
      }
      // console.log(this.details);
    },
    callback() {
      this.$emit('popupBtnCallback', this.number)
      this.popupShow = false
    }
  }
}
</script>

<style lang="scss">
.popup {
  box-sizing: border-box;
  padding: 34rpx 32rpx 68rpx;

  &-good {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 90rpx;

    image {
      width: 210rpx;
      height: 210rpx;
      border-radius: 12rpx;
      overflow: hidden;
    }

    .goodRight {
      box-sizing: border-box;
      padding-top: 25rpx;
      margin-left: 22rpx;
      flex: 1;
      text-align: left;
      color: $priceText;
      font-size: 24rpx;
      font-weight: 400;
    }
  }

  &-number {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: rgba(0, 0, 0, 0.55);
    font-size: 28rpx;
    font-weight: 400;

    .numberRight {
      flex: 1;
      text-align: right;

      text {
        margin: 0 10rpx;
        display: inline-block;
        width: 56rpx;
        height: 56rpx;
        line-height: 56rpx;
        background: rgba(245, 245, 245, 1);
        color: rgba(51, 51, 51, 1);
        font-size: 28rpx;
        text-align: center;
      }

      image {
        width: 16rpx;
        height: 32rpx;
        vertical-align: middle;
        margin-left: 10rpx;
      }
    }

    .allPrice {
      margin-top: 24rpx;
      box-sizing: border-box;
      padding-top: 12rpx;
      border-top: 1rpx solid #e5e5e5;
      flex: 1;
      text-align: right;
      color: $priceText;
    }
  }

  &-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: rgba(0, 0, 0, 0.55);
    font-size: 28rpx;
    font-weight: 400;
    box-sizing: border-box;
    // padding: 15rpx 0;

    .rowRight {
      flex: 1;
      text-align: right;
      color: #000;

      image {
        width: 16rpx;
        height: 32rpx;
        vertical-align: middle;
        margin-left: 10rpx;
      }
    }

    .price {
      color: $priceText;
    }
  }

  &-btn {
    height: 88rpx;
    margin: 230rpx auto 0;
    border-radius: 600rpx;
    opacity: 1;
    background: rgba(128, 110, 254, 1);
    color: rgba(255, 255, 255, 1);
    font-size: 32rpx;
    font-weight: 500;
    text-align: center;
    line-height: 88rpx;
    letter-spacing: 0.6rpx;
  }
}
</style>
